from django.shortcuts import render
from rest_framework.permissions import IsAuthenticated
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import status
from rest_framework.generics import ListAPIView, CreateAPIView
from rest_framework.generics import RetrieveAPIView, UpdateAPIView, DestroyAPIView
from .models import BannerModel
from .serializers import BannerModelSerializer


# 列表试图和创建试图
class BannerListAPIView(ListAPIView, CreateAPIView):
    # 权限检查
    # permission_classes = [IsAuthenticated]

    queryset = BannerModel.objects.all()
    serializer_class = BannerModelSerializer


# 获取试图，更新试图，删除试图
class BannerDetailAPIView(RetrieveAPIView, UpdateAPIView, DestroyAPIView):
    # 权限检查
    # permission_classes = [IsAuthenticated]

    queryset = BannerModel.objects.all()
    serializer_class = BannerModelSerializer
